#include <iostream>
#include <string.h>
using namespace std;
const int inf=0x7fffffff;



int main(){
	int n,k;
	cin>>n>>k;
	k++;
	int s[k+1];
	memset(s,0,sizeof(s));
	for(int i=0;i<n;i++){
		int l;
		cin>>l;
		if(i < k){
			s[i] = l;
			continue;
		}
		s[k] = l;
		int index=k-1;
		while(index >= 0  &&  s[index] > s[index+1]){
			int t=s[index];
			s[index] = s[index+1];
			s[index+1] = t;
			index--;
		}
	}
	cout<<s[k-1];
	return 0;
}
